package com.zhitan.netty.enums;

public enum CardStartErrorCodeEnum {

    ACCOUNT_NOT_EXIST((byte) 1, "账户不存在"),
    ACCOUNT_FREEZE((byte) 2, "账户冻结"),
    ACCOUNT_NO_MONEY((byte) 3, "账户余额不足"),
    CARD_HAS_UN_OVER_DEAL((byte) 4, "该卡存在未结账记录"),
    PILE_STOPED((byte) 5, "桩停用"),
    CAN_NOT_MATCH((byte) 6, "该账户不能在此桩上充电"),
    PASSWORD_ERROR((byte) 7, "密码错误"),
    ELECTRIC_CAPACITY_LESS((byte) 8, "电站电容不足"),
    VIN_NOT_EXIST((byte) 9, "系统中 vin 码不存在"),
    PILE_HAS_UN_OVER_DEAL((byte) 0x0A, "该桩存在未结账记录"),
    PILE_NOT_SUPPORT_CARD((byte) 0x0B, "该桩不支持刷卡");

    private byte code;
    private String message;

    CardStartErrorCodeEnum(byte code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(byte code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static CardStartErrorCodeEnum match(int key) {
        CardStartErrorCodeEnum result = null;
        for (CardStartErrorCodeEnum s : values()) {
            if (s.getCode() == key) {
                result = s;
                break;
            }
        }
        return result;
    }

    public static CardStartErrorCodeEnum catchMessage(String msg) {
        CardStartErrorCodeEnum result = null;
        for (CardStartErrorCodeEnum s : values()) {
            if (s.getMessage().equals(msg)) {
                result = s;
                break;
            }
        }
        return result;
    }
}
